const express = require('express');
const router = express.Router();
const protocolController = require('../controllers/protocolController');
const { verifyToken } = require('../middleware/authMiddleware');

// 所有路由都需要认证
router.use(verifyToken);

// 创建协议
router.post('/', protocolController.createProtocol);

// 获取用户的所有协议
router.get('/', protocolController.getUserProtocols);

// 获取分类下的所有协议
router.get('/category/:categoryId', protocolController.getProtocolsByCategory);

// 获取协议详情
router.get('/:id', protocolController.getProtocolById);

// 更新协议
router.put('/:id', protocolController.updateProtocol);

// 删除协议
router.delete('/:id', protocolController.deleteProtocol);

// 添加协议元素
router.post('/:id/elements', protocolController.addProtocolElement);

// 更新协议元素
router.put('/:id/elements/:elementId', protocolController.updateProtocolElement);

// 删除协议元素
router.delete('/:id/elements/:elementId', protocolController.deleteProtocolElement);

// 获取元素库
router.get('/elements/library', protocolController.getElementLibrary);

module.exports = router;
